{% extends 'base.html' %}
{% block title %}四Y-登录{% endblock %}
{% block css %}
    <link rel="stylesheet" href="/static/css/login_form-style.css">
        <link rel="stylesheet" href="/static/css/bootstrap-icons.css">
{% endblock %}


{% block content-center %}
    <div class="content-center" id="login-div">
        <form class="login_form" action="/login/" method="post">
            <h1>登录</h1>
            <div class="input-box">
                <input {% if error %} value="{{ username }}" {% endif %} tabindex="1" id="username" name="username"
                                      type="text" autocomplete="off" required>
                <label for="username">账号:</label>
            </div>
            <div class="input-box">
                <input tabindex="2" name="password" id="password" type="password" required>
                <label for="password">密码:</label>
            </div>

            <p class="error">{% if error %}账号或密码有误{% endif %}</p>


            <i class="bi bi-person"></i><input onclick="check_account()" tabindex="3" type="submit" value="登 录">
        </form>
        <a id="a_register" href="/register">点击注册</a>
        <p id="Forgot"><a style="margin-left: 90px;" href="/Forget">忘记密码</a></p>
    </div>

{% endblock %}

{% block body %}
{% endblock %}

{% block footjs %}
    <script src="/static/js/jquery.min.js" type="text/javascript"></script>
    <script>
        function check_account() {
            var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
            var username = $('#username').val();
            var password = $('#password').val();
            var isok = reg.test(username)
            if (!isok) {
                console.log(111)
                $('.error').html("邮箱格式不正确");
            }
        }
    </script>
{% endblock %}
